/*
 ============================================================================
 Name		: ImageUtils.h
 Author	  : Lenka Litvova
 Version	 : 1.0
 Copyright   : Your copyright notice
 Description : CImageUtils declaration
 ============================================================================
 */

#ifndef IMAGEUTILS_H
#define IMAGEUTILS_H

// INCLUDES
#include <e32std.h>
#include <e32base.h>
#include <FBS.H> //CFbsBitmap, TBitmapUtil header file
#include <ncvImage.h> //NokiacVImage
#include "Area.h"

// CLASS DECLARATION

/**
 *  CImageUtils
 * 
 */
class CImageUtils : public CBase
	{
public:
	// Constructors and destructor

	/**
	 * Destructor.
	 */
	~CImageUtils();

	/**
	 * Two-phased constructor.
	 */
	static CImageUtils* NewL();

	/**
	 * Two-phased constructor.
	 */
	static CImageUtils* NewLC();
	
	/**
	 * Funtion used to copy a CFbsBitmap for working on. Changing the returned copy
	 * does not affect the original.
	 */
	static CFbsBitmap* CopyImageL(CFbsBitmap *aImage);
	
	static CNokiaCVImage* CopyImageCVL(CNokiaCVImage *aImage);
	
	/**
	 * Function check the color and return true if it is a face color.
	 */
	static TBool IsFaceColorRGB(TRgb aColor);
	
	/**
	 * Function that searches connected pixels from the begin and when they
	 * have facecolor they are added to area that is returned.
	 */
	static CArea* FillFaceAreaL(CFbsBitmap *aImage, TPoint aBegin);
	
	static CArea* FillFaceAreaCVL(CNokiaCVImage* aImage, TPoint aBegin);
	
	static CArea* FillNonFaceAreaBWCVL(CNokiaCVImage *aImage, TPoint aBegin, CArea *face);
	
	/**
	  * Function that searches connected pixels from the begin and when they
	  * have non facecolor they are added to area that is returned.
	  */
	static CArea* FillNonFaceAreaL(CFbsBitmap *aImage, TPoint aBegin, CArea *face);
	
	static CArea* FillNonFaceAreaCVL(CNokiaCVImage* aImage, TPoint aBegin, CArea *face);
	
	/**
	  * Function that searches connected pixels from the begin and when they
	  * have non black color (edges are non black ) they are added to area that is returned.
	  */
	static CArea* FillEdgeAreaL(CFbsBitmap *aImage, TPoint aBegin, CArea *face);
	
	static CArea* FillEdgeAreaCVL(CNokiaCVImage* aImage, TPoint aBegin, CArea *face);
	
	/**
	  * Performs sobel filter on image aImage in the area of face (the rest of the image
	  * is out of recognition concern).
	  */
	static CFbsBitmap* DoSobel(CNokiaCVImage *aImage, CArea *face);
	
	static CNokiaCVImage* DoOwnSobelCV(CNokiaCVImage *aImage, CArea *face);
	
	/**
	  * Performs sobel filter on image aImage in the area of face (the rest of the image
      * is out of recognition concern).
	  */
	static CNokiaCVImage* DoSobelCV(CNokiaCVImage *aImage);
	
	/**
	  * Performs median filter on image aImage in the area of face (the rest of the image
	  * is out of recognition concern).
	  */
	static CNokiaCVImage* DoMedianCV(CNokiaCVImage *aImage);
	
	/**
	 * Function removes sample pixels.
	 */
	static void ClearImage(CNokiaCVImage *aImage, TInt aLevel, CArea *aFace);//, TInt aNosePos);
	
	/**
	 * Function convert aImage to a black-white image, where white pixels
	 * are those which had face color.
	 */
	static void ConvertFaceColorWhite(CNokiaCVImage *aImage, CArea *aFace);
	
	/**
	  * Function removes sample pixels.
	  */
	static TReal GetPointDistance(TPoint aPoint1, TPoint aPoint2);

public: //help functions
	static void ShowFaceColor(CNokiaCVImage *aImage);
	
private:

	/**
	 * Constructor for performing 1st stage construction
	 */
	CImageUtils();

	/**
	 * EPOC default constructor for performing 2nd stage construction
	 */
	void ConstructL();

	};

#endif // IMAGEUTILS_H
